package com.daxue.configtest.config;

import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;

/**
 * @author daxue0929
 * @date 2023/4/3
 */

@Configuration
public class ErrorPageConfig {

    /**
     * 配置的没有问题，但是404.html文件，css没有写好。
     * @return
     */
    @Bean
    public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer() {
        ErrorPage errorPage = new ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
        return (container -> container.addErrorPages(errorPage));
    }
}
